Skip to content

fix(ml): degrade to statistical features on any extractor failure, implement download-models#154

Merged
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z
Jul 10, 2026
Merged

fix(ml): degrade to statistical features on any extractor failure, implement download-models#154
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z

Conversation

@Liohtml

@Liohtml Liohtml commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

extract_features only caught ImportError ("torch not installed"), but the ResNet18 path also downloads ImageNet weights from download.pytorch.org on first use. In an air-gapped environment — the deployment the "on-device" pitch targets — that download raises URLError/RuntimeError and crashed the whole ml_analysis step instead of falling back.

Fixes #137

Changes

  • src/medcheck/pipeline/ml_analysis.py: split into _resnet_features / _statistical_features; extract_features now degrades to the statistical fallback on any extractor failure, logging the reason
  • src/medcheck/main.py: implement the download-models stub — builds the feature extractor once to pre-cache the weights (clear error + exit 1 when torch is missing or the download fails)
  • README.md: document the one-time model download and the medcheck download-models pre-fetch for offline environments (previous wording implied no network access at all)
  • Tests: 2 new extract_features fallback tests (RuntimeError download failure, ImportError), 2 new CLI tests for download-models

Testing

  • Existing tests pass (uv run pytest) — 184 passed
  • New tests added for new functionality — 4 new tests
  • Coverage does not decrease (uv run pytest --cov-fail-under=85) — 88.28%
  • Linting passes (uv run ruff check .)
  • Type checking passes (uv run mypy src/medcheck --strict)
  • Pre-commit hooks pass — ruff hooks pass locally; full pre-commit not run

🤖 Generated with Claude Code

https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9


Generated by Claude Code

…plement download-models

extract_features only caught ImportError, but the ResNet18 path also
downloads ImageNet weights from download.pytorch.org on first use — in
an air-gapped environment that raises URLError/RuntimeError and crashed
the whole ml_analysis step instead of falling back. Any extractor
failure now degrades to the statistical features with a logged reason.

The 'medcheck download-models' stub is now implemented: it pre-caches
the weights so local analysis runs fully offline afterwards, and the
README documents the one-time download (the previous wording implied no
network access at all).

Fixes #137

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Liohtml, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 855b7f71-f2b3-4023-9386-112ba1bd0dd6

📥 Commits

Reviewing files that changed from the base of the PR and between 0336537 and bfb5bb8.

📒 Files selected for processing (5)
  • README.md
  • src/medcheck/main.py
  • src/medcheck/pipeline/ml_analysis.py
  • tests/unit/test_cli.py
  • tests/unit/test_pipeline/test_ml_analysis.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dependabot-prs-q6u94z

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/medcheck/main.py 75.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Liohtml Liohtml merged commit 9734eca into main Jul 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants